import request from "@/utils/request";

/**
 * 客户管理列表
 * @param { CustomManageList } params
 */
// export const listManage = params => {
//   return request({
//     url: "/crm/info/listManage",
//     method: "get",
//     params
//   });
// };

/**
 * 客户管理列表
 * @param { CustomManageListBody } data
 * @param { CustomManageList } params
 */
export const listManage = (data, params) => {
  return request({
    url: `/crm/info/listManageWeb?current=${params.current}&size=${params.size}`,
    method: "post",
    data
  });
};

/**
 * 客户管理列表表头
 * @returns { Array<CustomManageTableHeaderItem> }
 */
export const customManageTableHeader = () => {
  return request({
    url: "/crm/group/getmeterheader",
    method: "get"
  });
};

/**
 * 自定义表头获取非字典数据
 * @param { string } params.method
 */
export const nonDictData = params => {
  return request({
    url: "/crm/remote/getData",
    method: "get",
    params
  });
};

/**
 * 客户管理列表 表头排序
 * @param { Array<string> } data
 */
export const tableHeaderSort = data => {
  return request({
    url: "/crm/field/addFieldConfig",
    method: "post",
    data
  });
};
/**
 * 获取客户管理列表 表头排序
 * @returns { TableHeaderSortData }
 */
export const tableHeaderSortData = () => {
  return request({
    url: "/crm/field/user/detail",
    method: "get"
  });
};

/**
 * 客户分组列表
 * @returns { Array<GroupListItem> }
 */
export const groupList = () => {
  return request({
    url: "/crm/group/getGroupNameShow",
    method: "get"
  });
};
/**
 * 分组拖动排序
 * @param { Array<{customerGroupId}> } data
 */
export const groupSort = data => {
  return request({
    url: "/crm/group/addGroupSort",
    method: "post",
    data
  });
};

/**
 * 新建客户
 * @param { CustomAdd } data
 */
export const addClientInfo = data => {
  return request({
    url: "/crm/info/add",
    method: "post",
    data
  });
};

/**
 * 查重
 * @param { string } mobileCode
 */
export const customCheckCrm = mobileCode => {
  return request({
    url: `/crm/info/getPlagiarismCheck/${mobileCode}`,
    method: "get"
  });
};

/**
 * 分配、移交
 * @param { AssignParams } data
 */
export const clientAssign = data => {
  return request({
    url: "/crm/info/addAssign",
    method: "post",
    data
  });
};

/**
 * 重置客户
 */
export const resetClientInfo = customerId => {
  return request({
    url: `/crm/build/task/resetTask/${customerId}`,
    method: "get",
    overtime: "20000"
  });
};

/**
 * 当前用户可分配角色
 */
export const getAssignRole = () => {
  return request({
    url: "/crm/system/getAllAssignRoleList",
    method: "get"
  });
};

/**
 * 客户基本信息 + 跟进记录
 * @param { string } customerId
 */
export const clientInfoAndFollow = customerId => {
  return request({
    url: `/crm/info/getInfoPenetration/${customerId}`,
    method: "get"
  });
};

/**
 * 新增客户跟进
 * @param { CustomTrackAdd } data
 */
export const addTrack = data => {
  return request({
    url: "/crm/track/add",
    method: "post",
    data
  });
};

/**
 * 服务团队
 * @param { string } customerId
 * @returns { Array<ServiceTeamData> }
 */
export const getServiceTeam = customerId => {
  return request({
    url: `/crm/info/getServiceTeam/${customerId}`,
    method: "get"
  });
};

/**
 * 客户阶段列表
 * @param { string } customerId -客户ID
 * @returns { Array<ClientStageData> }
 */
export const getStageList = customerId => {
  return request({
    url: `/crm/info/stage/list/${customerId}`,
    method: "get"
  });
};

/**
 * 客户阶段——办理CRM流程任务
 * @param { string } stageTaskId -客户阶段任务ID
 * @param { TaskHandleParams } data
 */
export const subStageViewContent = (stageTaskId, data) => {
  return request({
    url: `/crm/info/transact/${stageTaskId}`,
    method: "post",
    data
  });
};

/**
 * 任务管理——办理CRM流程任务
 * @param { string } commTaskId
 * @param { TaskHandleParams } data
 */
export const handleProcessTask = (commTaskId, data) => {
  return request({
    url: `/crm/workbench/transactAdmin/${commTaskId}`,
    method: "post",
    data
  });
};

/**
 * 修改办理后的CRM流程任务
 * @param { string } stageTaskId
 * @param { TaskHandleParams } data
 */
export const editProcessTask = (stageTaskId, data) => {
  return request({
    url: `/crm/build/task/updateTaskData/${stageTaskId}`,
    method: "post",
    data
  });
};

/**
 * 客户阶段内容视图
 * @param { string } customerId -客户ID
 */
export const getStageView = customerId => {
  return request({
    url: `/crm/info/stage/content/${customerId}`,
    method: "get"
  });
};

/**
 * 导入模板
 */
export const importTemplate = () => {
  return request({
    url: "/crm/excel/importCrmCustomerInfoTemplate",
    method: "post",
    responseType: "blob"
  });
};
/**
 * 验收计划列表
 * @param { string } customerId -客户ID
 * @param modelId
 */
export const getAcceptanceList = (customerId, modelId) => {
  return request({
    url: `/crm/checkStandard/businessList/${customerId}`,
    method: "get",
    params: {
      modelId
    }
  });
};
/**
 * 验收配置设置
 * @param { string } customerId -客户ID
 * @param data
 */
export const editAcceptance = (customerId, data) => {
  return request({
    url: `/crm/checkStandard/editBusinessCheck/${customerId}`,
    method: "put",
    data
  });
};

/**
 * 获取动态验收计划模块名
 * @param { string } customerId -客户ID
 */
export const acceptanceModule = customerId => {
  return request({
    url: `/crm/checkStandard/getModelName/${customerId}`,
    method: "get"
  });
};

/**
 * 提交资料
 * @param { string } checkId
 * @param data
 */
export const submitAcceptancePlanInfo = (checkId, data) => {
  return request({
    url: `/crm/checkStandard/submitAcceptance/${checkId}`,
    method: "put",
    data
  });
};

/**
 * 获取提交资料信息
 * @param { string } checkId
 */
export const acceptancePlanInfo = checkId => {
  return request({
    url: `/crm/checkStandard/getCheckAcceptanceDataInfo/${checkId}`,
    method: "get"
  });
};

/**
 * 校验提交导入
 */
export const importCrmconfirm = imports => {
  return request({
    url: `/crm/excel/importCrmconfirm/${imports}`,
    method: "get",
    overtime: 300000
  });
};

/**
 * 获取客户管理列表导出表头
 * @returns { customerExportHeader }
 */
export const customerExportHeader = () => {
  return request({
    url: "/crm/field/all",
    method: "get"
  });
};

/**
 * 获取客户管理列表导出表头
 * @returns { customerExport }
 */
export const customerExport = data => {
  return request({
    url: "/crm/excel/exportCrmCustomerList",
    method: "post",
    responseType: "blob",
    overtime: 60000,
    data
  });
};
/**
 * 判断客户是否重复
 */
export const checkRepeat = customerName => {
  return request({
    url: `/crm/info/existByCustomerName/${customerName}`
  });
};

/**
 * 客户导入
 */
export const customerImport = data => {
  return request({
    url: `/crm/excel/importCrmCustomerInfo`,
    method: "post",
    data,
    headers: { "Content-Type": "multipart/form-data" },
    overtime: 300000
  });
};
/**
 * 新建客户
 * @param { CustomAdd } data
 */
export const manageList = data => {
  return request({
    url: "/contract/info/manage/pageList",
    method: "post",
    data
  });
};

/**
 * 查看合同
 *
 */
export const contract = contractId =>
  request({
    url: "/contract/info/manage/" + contractId,
    method: "get"
  });

/**
 * 客户导入--检查导入成功状态
 */
export const checkImportStatus = imports => {
  return request({
    url: `/crm/excel/checkImport/${imports}`,
    method: "get"
  });
};
/**
 * 客户移交--查询角色
 * @param params - 查询参数
 */
export const roleList = params => {
  return request({
    url: `/sass/role/list`,
    method: "get",
    params
  });
};
/**
 * 客户移交--根据角色查询用户
 * @param params - 查询参数
 */
export const userNameByRoleId = params => {
  return request({
    url: `/sass/dept/getUserName`,
    method: "get",
    params
  });
};
/**
 * 客户移交--保存
 * @param data - 提交参数
 */
export const saveTransferInfo = data => {
  return request({
    url: `/crm/info/addTransfer`,
    method: "post",
    data,
    overtime: "120000"
  });
};
/*
 * 获取分享链接
 * */
export const share = () => {
  return request({
    url: "/contract/info/manage/share",
    method: "get"
  });
};
/**
 * 申请开工-详情
 * @param customerId - 客户id
 */
export const applyWorkDetail = customerId => {
  return request({
    url: `/crm/build/start/apply/${customerId}`,
    method: "get"
  });
};

/**
 * 申请开工--提交
 * @param data - 客户id
 */
export const applyWorkSubmit = data => {
  return request({
    url: `/crm/build/start/submit`,
    method: "post",
    data
  });
};
/**
 * 批量分配
 * @param data
 */
export const multipleAllocation = data => {
  return request({
    url: "/crm/info/addAssign",
    method: "post",
    data
  });
};
